package com.atguigu.config;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @PACKAGE_NAME: com.atguigu.config
 * @CLASSNAME: CustomAccessDeineHandler
 * @AUTHOR: zhangsan
 * @DATE: 2024/5/5 16:37
 * @SINCE 17.0.7
 * @DESCRIPTION: TODO
 */
public class CustomAccessDeniedHandler implements AccessDeniedHandler {
    /**
     * Handles an access denied failure.
     */
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
        //重定向到frame/auth页面
        response.sendRedirect("/auth");
    }
}
